import * as constants from './constants'
import {fromJS} from 'immutable'

export const changeSearchKeys = () => {

    let keys = ['PHP', '区块链', '小程序','故事', 'flutter', 'vue', '毕业',  '理财', '美食投稿']
    return (dispatch)=>{
        setTimeout(()=>{
            dispatch(searchKeys(keys))
        },300)
    }
}

export const mouseEnter = () => ({
    type: constants.MOUSE_ENTER
})
export const mouseLeave = () => ({
    type: constants.MOUSE_LEAVE
})

export const fetchSearchKeys = () => {
    return (dispatch) => {
        let keys = ['区块链', '小程序', 'vue', '毕业', 'PHP', '故事', 'flutter', '理财', '美食投稿']
        setTimeout(() => {
            dispatch(searchKeys(keys))
        }, 100)
    }
}

const searchKeys = (value) => ({
    type: constants.FETCH_SEARCH_KEYS,
    value: fromJS(value)
});

export const focus = () => ({
    type: constants.FOCUS
});

export const blur = () => ({
    type: constants.BLUR
})

export const inputValueChange = (value) => ({
    type: constants.SEARCH_VALUE_CHANGE,
    value: value
});